<?php
/**
 * 自动创建sn
 * Enter description here ...
 * @author nijn
 *
 */
class AutoSnBehavior extends CActiveRecordBehavior{
	public $attribute = '';
	public function beforeValidate($event) {
		if ($this->owner->isNewRecord) {
			$this->owner->{$this->attribute} = $this->createSn();
		}
	}
	
	public function createSn() {
		return date('Ymd').time();
	}
}

?>